// Copyright (c) MatrixFramework. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.ComponentModel.DataAnnotations;

namespace MatrixFramework.Photos.Domain.ValueObjects;

/// <summary>
/// 照片元数据值对象
/// </summary>
public class PhotoMetadata
{
    /// <summary>
    /// 拍摄设备制造商
    /// </summary>
    [MaxLength(100)]
    public string? Make { get; set; }

    /// <summary>
    /// 拍摄设备型号
    /// </summary>
    [MaxLength(100)]
    public string? Model { get; set; }

    /// <summary>
    /// 软件版本
    /// </summary>
    [MaxLength(200)]
    public string? Software { get; set; }

    /// <summary>
    /// 拍摄时间（EXIF）
    /// </summary>
    public DateTime? ExifDateTime { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? DateTimeModified { get; set; }

    /// <summary>
    /// 数字化时间
    /// </summary>
    public DateTime? DateTimeDigitized { get; set; }

    /// <summary>
    /// 图片宽度
    /// </summary>
    public int? Width { get; set; }

    /// <summary>
    /// 图片高度
    /// </summary>
    public int? Height { get; set; }

    /// <summary>
    /// 分辨率X
    /// </summary>
    public double? ResolutionX { get; set; }

    /// <summary>
    /// 分辨率Y
    /// </summary>
    public double? ResolutionY { get; set; }

    /// <summary>
    /// 分辨率单位
    /// </summary>
    [MaxLength(20)]
    public string? ResolutionUnit { get; set; }

    /// <summary>
    /// 曝光时间
    /// </summary>
    public double? ExposureTime { get; set; }

    /// <summary>
    /// 光圈值
    /// </summary>
    public double? FNumber { get; set; }

    /// <summary>
    /// ISO感光度
    /// </summary>
    public int? ISOSpeed { get; set; }

    /// <summary>
    /// 焦距
    /// </summary>
    public double? FocalLength { get; set; }

    /// <summary>
    /// 闪光灯模式
    /// </summary>
    public bool? Flash { get; set; }

    /// <summary>
    /// 白平衡
    /// </summary>
    [MaxLength(50)]
    public string? WhiteBalance { get; set; }

    /// <summary>
    /// 色彩空间
    /// </summary>
    [MaxLength(50)]
    public string? ColorSpace { get; set; }

    /// <summary>
    /// GPS纬度
    /// </summary>
    public double? GpsLatitude { get; set; }

    /// <summary>
    /// GPS经度
    /// </summary>
    public double? GpsLongitude { get; set; }

    /// <summary>
    /// GPS海拔
    /// </summary>
    public double? GpsAltitude { get; set; }

    /// <summary>
    /// GPS位置描述
    /// </summary>
    [MaxLength(500)]
    public string? GpsLocation { get; set; }

    /// <summary>
    /// 相机方向
    /// </summary>
    public int? Orientation { get; set; }

    /// <summary>
    /// 压缩率
    /// </summary>
    public int? Compression { get; set; }

    /// <summary>
    /// 位深度
    /// </summary>
    public int? BitsPerSample { get; set; }

    /// <summary>
    /// 原始数据（JSON格式）
    /// </summary>
    public string? RawData { get; set; }

    /// <summary>
    /// 元数据提取时间
    /// </summary>
    public DateTime ExtractedAt { get; set; }

    public PhotoMetadata()
    {
        ExtractedAt = DateTime.UtcNow;
    }

    /// <summary>
    /// 检查是否有GPS信息
    /// </summary>
    public bool HasGpsInfo => GpsLatitude.HasValue && GpsLongitude.HasValue;

    /// <summary>
    /// 检查是否有拍摄信息
    /// </summary>
    public bool HasCameraInfo => !string.IsNullOrEmpty(Make) || !string.IsNullOrEmpty(Model);

    /// <summary>
    /// 检查是否有EXIF信息
    /// </summary>
    public bool HasExifInfo => ExifDateTime.HasValue || Width.HasValue || Height.HasValue;
}